//
//  TopicTableViewCell.m
//  土巴兔
//
//  Created by 千锋 on 15/12/30.
//  Copyright (c) 2015年 IOS1503薛凯. All rights reserved.
//

#import "TopicTableViewCell.h"
#import "UIImageView+WebCache.h"
@implementation TopicTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createUI];
    }
    return self;
}
- (void)createUI{
    _titleLabel=[[UILabel alloc] init];
    _titleLabel.frame=CGRectMake(10, 10, DEVICEWIDTH-20, 20);
    [self.contentView addSubview:_titleLabel];
    
    _imageview=[[UIImageView alloc] initWithFrame:CGRectMake(10, 30, DEVICEWIDTH-20, (DEVICEWIDTH-20)*1/2)];
    _imageview.layer.cornerRadius=10;
    _imageview.clipsToBounds=YES;
    [self.contentView addSubview:_imageview];
    
    _context=[[UILabel alloc] init];
    _context.frame=CGRectMake(10, (DEVICEWIDTH-20)*1/2+30, DEVICEWIDTH, 50);
    _context.numberOfLines=0;
    _context.font=[UIFont systemFontOfSize:12];
    _context.alpha=0.8;
    [self.contentView addSubview:_context];
    _name=[[UILabel alloc] init];
    _name.frame=CGRectMake(10, (DEVICEWIDTH-20)*1/2+80, 60, 15);
    _name.font=[UIFont systemFontOfSize:12];
    _name.alpha=0.8;
    [self.contentView addSubview:_name];
    
    _time=[[UILabel alloc] init];
    _time.frame=CGRectMake(DEVICEWIDTH-70, (DEVICEWIDTH-20)*1/2+80, 60, 15);
    _time.font=[UIFont systemFontOfSize:12];
    _time.alpha=0.8;
    [self.contentView addSubview:_time];
}
- (void)relayoutWithModel:(MineModel*)model{
    if (model.title!=nil) {
        _titleLabel.text=model.title;
    }
    if (model.content!=nil) {
        _context.text=model.content;
    }
    if (model.filename!=nil) {
        [_imageview sd_setImageWithURL:[NSURL URLWithString:model.filename]];
    }
    if (model.name!=nil) {
        _name.text=model.name;
    }
    if (model.time!=0) {
         _time.text=[NSString stringWithFormat:@"%d",model.time];
    }
    
    
    
    
   
}
@end
